import { GCellRenderer } from "../../../../com/mui/controls/GCellRenderer";
import { ObjCreate } from "../common/ObjCreate";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { EMapPointType } from "../../../../Message/Public/EMapPointType";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { SServerKey } from "../../../../Message/Public/SServerKey";
import { GTextFiled } from "../../../../com/mui/controls/GTextFiled";
import { GButton } from "../../../../com/mui/controls/GButton";
//class TestPVPServerListRenderer
    
    export  class TestPVPServerListRenderer extends GCellRenderer
    {
        constructor()
        {
            super();
            this._proxyID = ObjCreate.createGTextField("", 0, 5, 70, 20, this, GlobalStyle.textFormat1);
            this._serverID = ObjCreate.createGTextField("", 75, 5, 60, 20, this, GlobalStyle.textFormat1);
            this._enterBtn1 = ObjCreate.createGButton("进入1", 150, 4, 49, 22, this);
            this._enterBtn2 = ObjCreate.createGButton("进入2", 205, 4, 49, 22, this);
            this._enterBtn3 = ObjCreate.createGButton("进入3", 260, 4, 49, 22, this);
            this._enterBtn1.drawNow();
            this._enterBtn2.drawNow();
            this._enterBtn3.drawNow();
            this._enterBtn1.addEventListener(flash.events.MouseEvent.CLICK, this.onEnterBtnClickHandler);
            this._enterBtn2.addEventListener(flash.events.MouseEvent.CLICK, this.onEnterBtnClickHandler);
            this._enterBtn3.addEventListener(flash.events.MouseEvent.CLICK, this.onEnterBtnClickHandler);
            return;
        }

        /* internal  */onEnterBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=0;
            var loc2=arg1.target;
            switch (loc2) 
            {
                case this._enterBtn1:
                {
                    loc1 = EMapPointType._EMapPointTypeCrossCountry1;
                    break;
                }
                case this._enterBtn2:
                {
                    loc1 = EMapPointType._EMapPointTypeCrossCountry2;
                    break;
                }
                case this._enterBtn3:
                {
                    loc1 = EMapPointType._EMapPointTypeCrossCountry3;
                    break;
                }
            }
            Dispatcher.dispatchEvent(new DataEvent(EventName.CrossPVP_enterCrossCountry, {"countryKey": data, "pointType": loc1}));
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = arg1;
            var loc1=arg1["serverKey"] as SServerKey;
            if (loc1) 
            {
                this._proxyID.htmlText = loc1.proxyId.toString();
                this._serverID.htmlText = loc1.serverId.toString();
            }
            return;
        }

        /* internal */ /* var */_serverID: GTextFiled;

        /* internal */ /* var */_proxyID: GTextFiled;

        /* internal */ /* var */_enterBtn1: GButton;

        /* internal */ /* var */_enterBtn2: GButton;

        /* internal */ /* var */_enterBtn3: GButton;
    }
